<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <canvas id="canvas" width="600" height="400"/>
    <script>
        var cv = document.getElementById("canvas");
        var ctx = cv.getContext('2d');
        // 画个三角形
        ctx.beginPath();
        ctx.moveTo(100,100);// 起点xy
        ctx.lineTo(100,200);// 目标点xy
        ctx.lineTo(200,200);
        ctx.lineTo(100,100);
        ctx.fill(); // 填充
        ctx.closePath();
    </script>
</body>
</html>